import { Component, OnInit, Input, Inject, forwardRef } from '@angular/core';
import { AlertController } from '@ionic/angular';
import { AppGlobalService } from '../../shared/service/app-global.service';
import { HttpService } from '../../shared/service/http.service';
import { zh_CN } from 'ng-zorro-antd-mobile';
import { isArray, isBoolean, isNumber } from 'util';
import { connect } from 'tls';
import { EventService } from '../../shared/service/event.service';
// import { TabsService } from 'src/app/shared/service/tabs.service';

import { FormGroup, FormControl, Validators, ValidatorFn, AbstractControl } from '@angular/forms';
import { jsonpCallbackContext } from '@angular/common/http/src/module';
import { JsonPipe } from '@angular/common';
@Component({
  selector: 'app-decoration-off',
  templateUrl: './decoration-off.component.html',
  styleUrls: ['./decoration-off.component.scss'],
})
export class DecorationOffComponent implements OnInit {
    @Input() tagData: any;
    formGroup: FormGroup = new FormGroup({});
    listdata: any;
    iftrue: boolean;
    appEditItem: any;
    tagDatas: any;
    ifadvertis: any; // 是否广告参数
    ifprepay: any; // 是否预付
    ifserveday: any; // 是否展示服务
    ifpicker: any; // 是否禁用具体位置
    advertisementlist: any; // 广告位数组
    advertisementlist2: any; // 广告位数组
    advertisementlist3: any; // 广告位数组
    sessionId: string;
    cycletext: any;
    areas: any;
    Status: any;
    test: any;
    ifcontract : any;
    // time
    locale = zh_CN;
    compareItemArray: any = [];
    constructor(
        private alert: AlertController,
        private appGlobalService: AppGlobalService,
        private http: HttpService,
        private eventService: EventService
    ) { }

    ngOnInit() {
        console.log(this.tagData)
        this.ifcontract = false;
        this.sessionId = localStorage.getItem('sessionId');
        this.tagData.data.advertisement.value = "text";
        this.Status = false;
        this.tagDatas = this.tagData.data;
        this.advertisementlist = this.tagDatas.advertisement.data;
        this.advertisementlist2 = JSON.stringify(this.tagDatas.advertisement.data);
        this.advertisementlist.forEach(element => {
            element.children.forEach(e => {
                if (e.children.length !== 0) {
                    e.children = "";
                }
            });
        });
        this.iftrue = false;
        this.ifadvertis = true;
        this.ifpicker = true;
        this.choosetimelimit(1);
        /* this.test=this.tagDatas.formObjs[2] */
        /* this.test = {
            "compare": false,
            "formType": "datePicker",
            "min": "2006-01-01",
            "hidden": false,
            "formKey": "quote_payment_time",
            "max": "2020-05-21",
            "showCheckAll": false,	
            "rules": [
                {
                    "name": "required",
                    "message": "请选择收款时间",
                    "value": "true"
                }
            ],
            "label": "收款日期"
        } */
        console.log(JSON.stringify(this.tagDatas.formObjs[2]))
        console.log(this.test)
    }
    async cancel() {
        let tip = "确定放弃本次发布？";
        if (this.tagDatas.title.indexOf('修改') !== -1) {
            tip = "是否放弃本次编辑？";
        }
        const alert = await this.alert.create({
            message: tip,
            buttons: [
                {
                    text: '取消',
                    role: 'cancel',
                    cssClass: 'secondary',
                    handler: () => {
                    }
                }, {
                    text: '确定',
                    cssClass: 'LJ',
                    handler: () => {
                        this.appGlobalService.goBack();
                        this.appGlobalService.popTarget();
                    }
                }
            ]
        });
        await alert.present();
    }
    choosetimelimit(e) {
        this.tagDatas.advertisement.textInputWithEndLabel.rules[0].value = "";
        if (e === 1) {
            this.tagDatas.cycle.forEach(element => {
                if (element.isCheck === "true") {
                    this.cycletext = element;
                    if (element.cycleFlag && element.isCheck === "true") {
                        this.ifserveday = true;
                    } else {
                    }
                }

            });
        } else {
            this.tagDatas.cycle.forEach(element => {
                if (element.name === e.name) {
                    element.isCheck = "true";
                    this.cycletext = element;
                    if (element.cycleFlag) {
                        this.ifserveday = true;
                        this.cycletext = element;
                    } else {
                        this.ifserveday = false;
                    }
                } else {
                    element.isCheck = "false";
                }
            });
        }
    }
    /* 选择广告位 */
    onOk2(result, type) {
        if (type === 1) {
            this.tagDatas.advertisement.placeHolder = result[0].label + result[1].label;
            JSON.parse(this.advertisementlist2).forEach(element => {
                element.children.forEach(e => {
                    if (e.code === result[1].code) {
                        this.advertisementlist3 = e.children;
                        this.ifpicker = false;
                        this.tagDatas.advertisement.subPlaceHolder = "具体位置";
                    }
                });
            });
        } else {
            this.tagDatas.advertisement.subPlaceHolder = result[0].label;
            if (this.tagDatas.advertisement.value) {
                this.tagDatas.advertisement.value = result[0].code;
            }
        }
    }
     // <!-- 选择付款方式-->
     onOk3(result, item , isArea?) {
        this.tagDatas.formObjs[3].placeHolder = result[0].label;
        this.tagDatas.formObjs[3].value = result[0].value;
      }
      // <!-- 选择凭证类型->
      onOk4(result, item , isArea?) {
        this.tagDatas.formObjs[6].placeHolder = result[0].label;
        this.tagDatas.formObjs[6].value = result[0].value;
     }
        // 更新图片数据
    updateUrlHandler(event) {
        console.log(event)
        /*  this.formGroup.patchValue({ [event.formKey]: event.value }); */
        this.tagDatas.formObjs[5].subHtmlObj[0].rules[0].value = event.value;
    }
    updateUrlHandlertwo(event) {
       this.tagDatas.formObjs[7].rules[0].value = event.value;
    }
    /* 提交 */
    offersubmit() {
        // content 值
        const contents = this.tagDatas.button.submit.content;
        // 提交id值
        const listid = this.tagDatas.button.submit.id;
        // 广告值
        // tslint:disable-next-line: variable-name
        const quote_ad_position = this.tagDatas.advertisement.formKey;
        // tslint:disable-next-line: variable-name
        const quote_ad_position_value = this.tagDatas.advertisement.value;
        // 广告天数的值
        const quotePrepayPrice = this.tagDatas.advertisement.textInputWithEndLabel.formKey;
        const day = this.tagDatas.advertisement.textInputWithEndLabel.rules[0].value;
        // 选择的服务月份的值
        // tslint:disable-next-line: variable-name
        const service_mode = this.cycletext.data[0].formKey;
        // tslint:disable-next-line: variable-name
        const service_modevalue = this.cycletext.data[0].value;
        // tslint:disable-next-line: variable-name
        let quote_service_days: string;
        // tslint:disable-next-line: variable-name
        let quote_service_daysvalue: string;
        if (this.cycletext.data.length > 1) {
            quote_service_days = this.cycletext.data[1].formKey;
            quote_service_daysvalue = this.cycletext.data[1].value;
        } else {
            quote_service_days = this.tagDatas.cycleForm.formKey;
            quote_service_daysvalue = this.tagDatas.cycleForm.rules[0].value;
            // tslint:disable-next-line: radix
            if (this.verificationfour(quote_service_daysvalue) === false) {
                this.appGlobalService.showToast(this.tagDatas.cycleForm.rules[1].message, 500, 'top');
                return;
            }
        }
        let daynum; daynum = quote_service_daysvalue;
        /*  const servicedata = JSON.parse('{' + '"' + quote_service_days + '"' + ":" + '"' + quote_service_daysvalue + '"' + '}'); */
        let servicedata; servicedata = { [quote_service_days]: quote_service_daysvalue };
        // 获取佣金比例
        const commissionkey = this.tagDatas.formObjs[0].formKey;
        const commission = this.tagDatas.formObjs[0].rules[0].value;
        // 获取推荐客户说明
        const recommendkey = this.tagDatas.formObjs[1].formKey;
        const recommend = this.tagDatas.formObjs[1].value;
        // 收款日期
        const gatheringdatekey = this.tagDatas.formObjs[2].formKey;
        const gatheringdate = this.tagDatas.formObjs[2].value;
        // 支付类型
        const paytypekey = this.tagDatas.formObjs[3].formKey;
        const paytype = this.tagDatas.formObjs[3].value;
        // 收款金额
        const paymoneykey = this.tagDatas.formObjs[4].formKey;
        const paymoney = this.tagDatas.formObjs[4].rules[0].value;
        // 上传合同图片
        const imgonekey = this.tagDatas.formObjs[5].subHtmlObj[0].formKey;
        const imgone = this.tagDatas.formObjs[5].subHtmlObj[0].rules[0].value;
        // 上传支付凭证
        const imgtwokey = this.tagDatas.formObjs[7].formKey;
        const imgtwo = this.tagDatas.formObjs[7].rules[0].value;
        console.log(imgone)
        let imgonearry;
        // tslint:disable-next-line: no-non-null-assertion
        /*  && this.tagDatas.formObjs[5].subHtmlObj[0].rules[0].value ! === "" */
        if ( this.ifcontract === true) {
            imgonearry = {
                [imgonekey] : imgone
            };
            if (imgone === "") {
                this.appGlobalService.showToast(this.tagDatas.formObjs[5].subHtmlObj[0].rules[0].message, 500, 'top');
                return;
            }
        }
        let imgtwoarry;
        // tslint:disable-next-line: no-non-null-assertion
        /* if ( this.tagDatas.formObjs[7].rules[0].value ! === "") { */
        imgtwoarry = {
            [imgtwokey] : imgtwo
        };
        /* } */
        console.log(imgonearry)
        console.log(imgtwoarry)
        // 合同编号
        const contractidkey = this.tagDatas.formObjs[5].subHtmlObj[1].formKey;
        const contractid = this.tagDatas.formObjs[5].subHtmlObj[1].rules[0].value;
        // 凭证类型
        const vouchertypekey = this.tagDatas.formObjs[6].formKey;
        const vouchertype = this.tagDatas.formObjs[6].value;
        // 支付订单号
        const payorderkey = this.tagDatas.formObjs[8].formKey;
        const payorder = this.tagDatas.formObjs[8].rules[0].value;
        // 收款备注
        const Creditnotekey = this.tagDatas.formObjs[9].formKey;
        const Creditnote = this.tagDatas.formObjs[9].value;
        // 支付收款相关
        const paylist = {
            [commissionkey]: commission,
            [recommendkey]: recommend,
            [gatheringdatekey]: gatheringdate,
            [paytypekey]: paytype,
            [paymoneykey]: paymoney,
            [contractidkey]: contractid,
            [vouchertypekey]: vouchertype,
            [payorderkey]: payorder,
            [Creditnotekey]: Creditnote,
        };
        // 是否需要广告位广告位的值
        let ifadvertising;
        if (this.ifadvertis === true) {
            ifadvertising = {
                [quote_ad_position]: quote_ad_position_value,
                [quotePrepayPrice]: day,
                [service_mode]: service_modevalue,
               /*  [quote_price]: quote_pricevalue */
            };
        } else {
            ifadvertising = {
                [service_mode]: service_modevalue,
               /*  [quote_price]: quote_pricevalue */
            };
        }
        // 相关验证
        if (this.verificationday(quote_service_daysvalue) === false) {
            // tslint:disable-next-line: max-line-length
            if (quote_service_daysvalue === "" || quote_service_daysvalue === undefined || quote_service_daysvalue === "true" || quote_service_daysvalue === null) {
                this.appGlobalService.showToast(this.tagDatas.cycleForm.rules[0].message, 500, 'top');
                return;
            } else {
                this.appGlobalService.showToast(this.tagDatas.cycleForm.rules[1].message, 500, 'top');
                return;
            }
        } else {
        }
        if (this.tagDatas.advertisement.value === "text" && this.ifadvertis === true) {
            this.appGlobalService.showToast('请选择广告位', 500, 'top');
            return;
        }
        if (this.verificationday1(day) === false) {
            // tslint:disable-next-line: max-line-length
            if ((day === "" && this.ifadvertis === true) || (day === "true" && this.ifadvertis === true) || (day == null && this.ifadvertis === true)) {
                this.appGlobalService.showToast(this.tagDatas.advertisement.textInputWithEndLabel.rules[0].message, 500, 'top');
                return;
            } else {
                this.appGlobalService.showToast(this.tagDatas.advertisement.textInputWithEndLabel.rules[1].message, 500, 'top');
                return;
            }
        } else {
            // tslint:disable-next-line: radix
            if (parseInt(day) < 0 || parseInt(day) > parseInt(daynum)) {
                this.appGlobalService.showToast("请填写正确的服务天数，1-" + daynum + "天之间", 500, 'top');
                return;
            }
        }
        /* 佣金比例为空判断 */
        if (this.verificationcommission(commission) === false) {
            this.appGlobalService.showToast("佣金比例请填写0-100内数字，可填写1位小数" , 500, 'top');
            return;
        }
        if (gatheringdate && gatheringdate !== undefined && gatheringdate !== true) {
        } else {
            this.appGlobalService.showToast("请选择日期" , 500, 'top');
            return;
        }
        if (paytype === "0" || paytype === "" || paytype === null) {
            this.appGlobalService.showToast("请选择收款方式" , 500, 'top');
            return;
        }
        if (vouchertype === "0" || vouchertype === ""||vouchertype === null) {
            this.appGlobalService.showToast("请选择凭证类型" , 500, 'top');
            return;
        }
        if (this.verificationcommission1(paymoney) === false){
            this.appGlobalService.showToast("收款金额请填写7位整数，可填写2位小数" , 500, 'top');
            return;
        }
        const contentsitem = JSON.stringify(contents);
        const content = Object.assign(
            JSON.parse(contentsitem),
            ifadvertising,
            servicedata,
            paylist,
            imgonearry,
            imgtwoarry
        );
        const params = {
            content,
            id: listid,
            sessionId: this.sessionId
        };
        this.Status = true;
        // 请求获取新数据
        this.http.post('application/submit', params, res => {
            // 请求数据成功
            if (res.success && res.data) {
                // 筛选数据
                this.appGlobalService.showToast(res.message, 2000, 'top');
                // tslint:disable-next-line:no-shadowed-variable
                const params = {
                    pageId: this.tagDatas.button.submit.target,
                    params: contents,
                    sessionId: localStorage.getItem('sessionId')
                };
                const that = this;
                setTimeout(() => {
                    // localStorage.setItem("fromPostOrEdit", 'true');
                    this.appGlobalService.goBack();
                    this.appGlobalService.popTarget();
                    // 刷新
                    this.appGlobalService.reloadCurrentPage();
                }, 1000);
            } else {
                this.Status = false;
                // 请求数据失败
                this.appGlobalService.showToast(res.message, 2000, 'middle');
            }
        });
    }
    // 预览合同
    previewcontract() {
        // tslint:disable-next-line: variable-name
        const quote_ad_position = this.tagDatas.advertisement.formKey;
        // tslint:disable-next-line: variable-name
        const quote_ad_position_value = this.tagDatas.advertisement.value;
        // 广告天数的值
        const quotePrepayPrice = this.tagDatas.advertisement.textInputWithEndLabel.formKey;
        const day = this.tagDatas.advertisement.textInputWithEndLabel.rules[0].value;
        // 选择的服务月份的值
        // tslint:disable-next-line: variable-name
        const service_mode = this.cycletext.data[0].formKey;
        // tslint:disable-next-line: variable-name
        const service_modevalue = this.cycletext.data[0].value;
        // tslint:disable-next-line: variable-name
        let quote_service_days;
        // tslint:disable-next-line: variable-name
        let quote_service_daysvalue;
        if (this.cycletext.data.length > 1) {
            quote_service_days = this.cycletext.data[1].formKey;
            quote_service_daysvalue = this.cycletext.data[1].value;
        } else {
            quote_service_days = this.tagDatas.cycleForm.formKey;
            quote_service_daysvalue = this.tagDatas.cycleForm.rules[0].value;
            // tslint:disable-next-line: radix
            if (this.verificationfour(quote_service_daysvalue) === false) {
                this.appGlobalService.showToast(this.tagDatas.cycleForm.rules[1].message, 500, 'top');
                return;
            }
        }
        const daynum = quote_service_daysvalue;
        /*   const servicedata = JSON.parse('{' + '"' + quote_service_days + '"' + ":" + '"' + quote_service_daysvalue + '"' + '}'); */
        const servicedata = { [quote_service_days]: quote_service_daysvalue };
        // 是否需要广告位广告位的值
        let ifadvertising;
        if (this.ifadvertis === true) {
            ifadvertising = {
                [quote_ad_position]: quote_ad_position_value,
                [quotePrepayPrice]: day,
                [service_mode]: service_modevalue,
            };
        } else {
            ifadvertising = {
                [service_mode]: service_modevalue,
            };
        }
        // 获取佣金比例
        const commissionkey = this.tagDatas.formObjs[0].formKey;
        const commission = this.tagDatas.formObjs[0].rules[0].value;
        // 获取推荐客户说明
        const recommendkey = this.tagDatas.formObjs[1].formKey;
        const recommend = this.tagDatas.formObjs[1].value;
        // 收款金额
        const paymoneykey = this.tagDatas.formObjs[4].formKey;
        const paymoney = this.tagDatas.formObjs[4].rules[0].value;
        // 佣金比例和推荐客户说明以及收款金额是预览合同时所需要的的值，为此放在一个数组
        let commissiondata;
        commissiondata = {
          [commissionkey]: commission,
          [recommendkey]: recommend,
          [paymoneykey]: paymoney
        };
        console.log(commissiondata)
        // 相关验证
        if (this.verificationday(quote_service_daysvalue) === false) {
            // tslint:disable-next-line: max-line-length
            if (quote_service_daysvalue === "" || quote_service_daysvalue === undefined || quote_service_daysvalue === "true" || quote_service_daysvalue === null) {
                this.appGlobalService.showToast(this.tagDatas.cycleForm.rules[0].message, 500, 'top');
                return;
            } else {
                this.appGlobalService.showToast(this.tagDatas.cycleForm.rules[1].message, 500, 'top');
                return;
            }
        } else {
        }
        if (this.tagDatas.advertisement.value === "text" && this.ifadvertis === true) {
            this.appGlobalService.showToast('请选择广告位', 500, 'top');
            return;
        }
        if (this.verificationday1(day) === false) {
            // tslint:disable-next-line: max-line-length
            if ((day === "" && this.ifadvertis === true) || (day === "true" && this.ifadvertis === true) || (day === null && this.ifadvertis === true)) {
                this.appGlobalService.showToast(this.tagDatas.advertisement.textInputWithEndLabel.rules[0].message, 500, 'top');
                return;
            } else {
                this.appGlobalService.showToast(this.tagDatas.advertisement.textInputWithEndLabel.rules[1].message, 500, 'top');
                return;
            }
        } else {
            // tslint:disable-next-line: radix
            if (parseInt(day) < 0 || parseInt(day) > parseInt(daynum)) {
                this.appGlobalService.showToast("请填写正确的服务天数，1-" + daynum + "天之间", 500, 'top');
                return;
            }
        }
        /* 佣金比例为空判断 */
        if (this.verificationcommission(commission) === false) {
            this.appGlobalService.showToast("佣金比例请填写0-100内数字，可填写1位小数" , 500, 'top');
            return;
        }
        /* 收款为空判断 */
        if (this.verificationcommission1(paymoney) === false){
            this.appGlobalService.showToast("收款金额请填写7位整数，可填写2位小数" , 500, 'top');
            return;
        }
        const type = {type: this.tagDatas.link.type}
        const content = Object.assign(
            ifadvertising,
            servicedata,
            commissiondata,
            type
        );
        const context = JSON.stringify(this.tagDatas.link.params);
        const contextdata = Object.assign(
            JSON.parse(context),
            content
        );
        const params = {
            pageId: this.tagDatas.link.target,
            params: contextdata,
            sessionId: localStorage.getItem('sessionId')
        };
        /* const paramsTEXT =JSON.stringify(params); */
        const that = this;
        if (this.tagDatas.link.type === 'contract') {
            localStorage.setItem('needRefresh', 'false');
            this.http.post('/element/serviceContract/url', params.params, res => {
                this.appGlobalService.openUrl(this.tagDatas.link.label, res.url, params.pageId, JSON.stringify(params.params));
            });
        } else if (this.tagDatas.link.type === 'decoration'){
            localStorage.setItem('needRefresh', 'false');
            this.http.post('/element/serviceContract/decorationurl', params.params, res => {
                this.appGlobalService.openUrl(this.tagDatas.link.label, res.url, params.pageId, JSON.stringify(params.params));
            });
        } else if (this.tagDatas.link.type === 'projectInv'){
            localStorage.setItem('needRefresh', 'false');
            this.http.post('/element/serviceContract/decorationurl', params.params, res => {
                this.appGlobalService.openUrl(this.tagDatas.link.label, res.url, params.pageId, JSON.stringify(params.params));
            });
        } else if (this.tagDatas.link.type === 'propertyInv'){
            localStorage.setItem('needRefresh', 'false');
            this.http.post('/element/serviceContract/decorationurl', params.params, res => {
                this.appGlobalService.openUrl(this.tagDatas.link.label, res.url, params.pageId, JSON.stringify(params.params));
            });
        } else {
            setTimeout(() => {
                // localStorage.setItem("fromPostOrEdit", 'true');
                localStorage.setItem('needRefresh', 'false');
                that.appGlobalService.goToForward(params);
            }, 1000);
        }
    }
        getDate(max, item) {
            if (item.max === max) {
            return item.maxDate = item.maxDate ? item.maxDate : this.getDateTime(max);
            } else if (item.min === max) {
            return item.minDate = item.mimDate ? item.minDate : this.getDateTime(max);
            }
        }
        datetime(result: Date, item) {
            item.value = this.currentDateFormat(result, 'yyyy-mm-dd HH:MM:ss');
            item.defValue = result;
           /*  this.test.defValue=item.defValue; */
            console.log(item.value)
            console.log(item.defValue)
            console.log(this.formGroup)
            this.formGroup.patchValue({[item.formKey] : item.value});
          }
          formatIt(date: Date, form: string) {
            const pad = (n: number) => (n < 10 ? `0${n}` : n);
            const dateStr = `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`;
            const timeStr = `${pad(date.getHours())}:${pad(date.getMinutes())}`;
            if (form === 'YYYY-MM-DD') {
              return dateStr;
            }
            if (form === 'HH:mm') {
              return timeStr;
            }
            return `${dateStr} ${timeStr}`;
          }
      getDateTime(date) {
        if (!date) {
          return;
        }
        if (date.indexOf(' ') > -1) {
          // console.log(new Date(Date.parse(date.replace(/-/g, "/"))));
          return new Date(Date.parse(date.replace(/-/g, "/")));
        } else {
          // console.log(new Date(Date.parse((date + ' ' + '23:59:59').replace(/-/g, "/"))));
          return new Date(Date.parse((date + ' ' + '23:59:59').replace(/-/g, "/")));
        }
      }
      currentValue(item) {
        if (!item.value || item.value === '') {
          return item.placeHolder;
        } else {
          return item.value;
        }
      }
    // 时间段选择
    currentDateFormat(date, format: string = 'HH:MM'): any {
        console.log(date)
        const pad = (n: number): string => (n < 10 ? `0${n}` : n.toString());
        return format
        .replace('yyyy', date.getFullYear())
        .replace('mm', pad(date.getMonth() + 1))
        .replace('dd', pad(date.getDate()))
        .replace('HH', pad(date.getHours()))
        .replace('MM', pad(date.getMinutes()))
        .replace('ss', pad(date.getSeconds()));
    }
      changeItemobjValidator() {
          console.log('this.ifcontract')
          this.ifcontract = !this.ifcontract;
          console.log(this.ifcontract)
      }
    verificationday(e) {
        const reg = /^[1-9]\d*$/;
        if (this.ifserveday === true) {
            return reg.test(e);
        } else {
            return true;
        }

    }
    verificationday1(e) {
        const reg = /^[1-9]\d*$/;
        if (this.ifadvertis === true) {
            return reg.test(e);
        } else {
            return true;
        }

    }
    verificationmoney(e) {
        const reg = /(?:^[-]?[1-9]\d{0,6}(?:$|(?:,\d{3})*(?:$|(\.\d{1,2}$))))|(?:(?:^[0](\.\d{1,2})?)|(?:^[-][0]\.\d{1,2}))$/;
        return reg.test(e);
    }
    verificationmoney1(e) {
        const reg = /(?:^[-]?[1-9]\d{0,6}(?:$|(?:,\d{3})*(?:$|(\.\d{1,2}$))))|(?:(?:^[0](\.\d{1,2})?)|(?:^[-][0]\.\d{1,2}))$/;
        if (this.ifprepay === true) {
            return reg.test(e);
        } else {
            return true;
        }
    }
    // 0-100保留一位小数
    verificationcommission(e) {
        const reg = /^(\d{1,2}(\.\d{1,2})?|100)$/;
        if ( e === "" || e === null) {
          return true;
        } else if ( e === 0 || e === "0" ) {
          return false;
        } else {
          return reg.test(e);
        }
      }
    // 7整数带2小数
    verificationcommission1(e) {
        const reg = /(?:^[-]?[1-9]\d{0,6}(?:$|(?:,\d{3})*(?:$|(\.\d{1,2}$))))|(?:(?:^[0](\.\d{1,2})?)|(?:^[-][0]\.\d{1,2}))$/;
        return reg.test(e);
    }
    // 四位正整数
    verificationfour(e) {
        const reg = /^[1-9]\d{0,3}$/;
        return reg.test(e);
    }
    ifprepayclick() {
        this.ifprepay = !this.ifprepay;
    }
    ifadvertisclick() {
        this.ifadvertis = !this.ifadvertis;
    }
}
